package com.helwen.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

/**
 * 生成id的工具类
 */
public class UuidSnakeCreateTool {

    //IdUtil.randomUUID()//一般的uuid
    /**
     * 生成字符串形式的id
     * @return
     */
    public static String getIdString(){
        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
        // 有两种返回值类型
        //long id = snowflake.nextId();
        String nextIdStr = snowflake.nextIdStr();
        return nextIdStr;
    }

    private static   Snowflake snowflake = IdUtil.createSnowflake(1, 1);

    /**
     * 生成long类型的id
     * @return
     */
    public static Long getIdLong(){
        // 有两种返回值类型
        long id = snowflake.nextId();
        //String nextIdStr = snowflake.nextIdStr();
        return id;
    }


}
